package com.kfm.hotel.controller;

import com.github.pagehelper.PageInfo;
import com.kfm.hotel.pojo.Room;
import com.kfm.hotel.pojo.SysUser;
import com.kfm.hotel.service.RoomService;
import com.kfm.hotel.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

@RestController
@RequestMapping("/room")
public class RoomController {

    @Autowired
    private RoomService roomService;

    @GetMapping
    public ModelAndView mv(){
        return new ModelAndView("room/index");
    }


    @GetMapping("/list")
    public R list(@RequestParam(defaultValue = "1") Integer pageNumber
            , @RequestParam(defaultValue = "5")Integer pageSize
            , Room room){
        return R.ok(roomService.listWithRoomType(pageNumber, pageSize, room));
    }

    @PostMapping
    public R add(Room room){
        roomService.saveRoom(room);
        return R.failed("添加失败");
    }
}
